import axios from 'axios'
import { BASE_URL } from '@config'
const instance = axios.create({
  baseURL: BASE_URL
})

// 添加请求拦截器
instance.interceptors.request.use(
  config => {
    return config
  },
  err => {
    Promise.reject(err)
  }
)

instance.interceptors.response.use(
  response => {
    return response
  },
  error => {
    Promise.reject(error)
  }
)

export const get = (url, params) =>
  instance.get(url, {
    params
  })

export const post = (url, params) => instance.post(url, params)
